package cn.mistorange.service;

import cn.mistorange.mapper.UserMapper;
import cn.mistorange.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserMapper userMapper;

    //添加新用户
    @Override
    public void createUser(User user) {
        user.setCreatedAt(LocalDateTime.now());
        userMapper.insertUser(user);
    }

    //批量删除用户
    @Override
    public void deleteUser(List<Integer> ids) {
        userMapper.deleteUser(ids);
    }

    //id查询
    @Override
    public User getUserById(Integer id) {
        User user = userMapper.findUserById(id);
        return user;
    }

    //修改信息
    @Override
    public void updateUser(User user) {
        userMapper.updateUser(user);
    }
}
